package leetcode.code1768;

import leetcode.IDebug;

public class Solution implements IDebug {

	public String mergeAlternately(String word1, String word2) {
		char[] cs1 = word1.toCharArray();
		int len1 = cs1.length;
		char[] cs2 = word2.toCharArray();
		int len2 = cs2.length;
		char[] ans = new char[len1 + len2];
		int p1 = 0, p2 = 0, p = 0;
		while (p1 < len1 && p2 < len2) {
			if ((p & 1) == 0) {
				ans[p++] = cs1[p1++];
			} else {
				ans[p++] = cs2[p2++];
			}
		}
		while (p1 < len1) {
			ans[p++] = cs1[p1++];
		}
		while (p2 < len2) {
			ans[p++] = cs2[p2++];
		}
		return new String(ans);
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
